package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "sdecl";

    private Button btnHello;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        btnHello = findViewById(R.id.btn_hello);

        // 设置按钮的点击事件
        btnHello.setOnClickListener((v) -> {
            Log.i(TAG, "setOnClickListener: ");
        });

        // 设置按钮的长按事件
        btnHello.setOnLongClickListener((v) -> {
            Log.i(TAG, "setOnLongClickListener: ");
            return false;
        });

        // 设置按钮触摸事件
        btnHello.setOnTouchListener((v, event) -> {
            Log.i(TAG, "setOnTouchListener: " + event.getAction());
            return false;
        });

    }
}